package com.x.Part8_多态;
/**
 * ClassName: Test
 * Package: IntelliJ IDEA
 * Description:
 * Written by HanXu
 * Create 2024/1/10 14:16
 */
public class AnimalTest {
    public void adopt(Animal animal){
        animal.eat();
        animal.work();
    }
    public static void main(String[] args) {
        AnimalTest test = new AnimalTest();

        //若无多态性，则只能在adopt里new Animal()
        //在这里new Cat()，则调用了具体猫的eat()和work()方法
        test.adopt(new Cat());
        System.out.println("**********");
        test.adopt(new Dog());

    }
}

